<?php
class Adminpage_permission_model extends MY_Model{
	function __construct(){
		parent::__construct();
		$this->loadfields();
	}
	
	public function loadallowedpages(){
		$this->db->where("obj.usergroup_id" , 1);
		$this->db->where("ap.valid" , VALID);
		$this->db->select("ap.name as pagename");
		$this->db->select("folder");
		$this->db->distinct("pagename");
		$this->db->join('adminpage as ap', 'ap.id= obj.adminpage_id');
		$this->db->order_by("ap._order");
		$result = $this->db->get($this->table()." as obj");
		return $result->result_array();
	}
	
	public function loadpermission($page){
		$this->db->where("obj.usergroup_id" , 1);
		$this->db->where("ap.name" , $page);
		$this->db->where("ap.valid" , VALID);
		$this->db->select("*");
		$this->db->select("ap.name as pagename");
		$this->db->join('adminpage as ap', 'ap.id= obj.adminpage_id');
		$result = $this->db->get($this->table()." as obj");
		
		return $result->row_array();
	}
}